package recursion;

import java.util.Scanner;

public class HanNouTa {
    public static void main(String[] args) {
        while (true) {
            System.out.print("玩几层汉诺塔：");
            int n = new Scanner(System.in).nextInt();
            f(n);
        }
    }

    private static void f(int n) {
        f(n, "A", "B", "C");
    }

    private static void f(int n, String from, String mid, String to) {
        if(n==1){
            System.out.printf("%s -> %s\n",from,to);
            return;
        }

        f(n-1,from,mid,to);
        f(1,from,mid,to);
        f(n-1,mid,from,to);
    }
}
